package com.ling.feign.plus.gson;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;

import java.io.IOException;

public class StackTraceElementTypeAdapter extends TypeAdapter<StackTraceElement> {
    @Override
    public void write(JsonWriter out, StackTraceElement value) throws IOException {

    }

    @Override
    public StackTraceElement read(JsonReader jsonReader) {
        Gson gson = new GsonBuilder()
                .registerTypeAdapter(String.class, new StringTypeAdapter())
                .registerTypeAdapter(int.class, new IntegerTypeAdapter())
                .create();
        return gson.fromJson(jsonReader, StackTraceElement.class);
    }
}
